import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.use(header);
  await app.listen(9020);
}
bootstrap();

function header(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Content-Type,X-Requested-With");
  res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
  res.header("X-Powered-By", 'NodeJs');
  //res.header("Content-Type", "application/x-www-form-urlencoded");
  //res.header("Content-Type", "application/json;charset=utf-8");
  res.header("Content-Type", "  application/octet-stream");
  //res.header("Content-Type", "text/plain;charset=utf-8");
  if (req.method == 'OPTIONS') {
    res.sendStatus(200);
  } else {
    next();
  }
}